<template>
  <div>
    <ul>
      <!-- 循环遍历的时候，必须加 :key 属性，属性值不能重复【原因下一天讲】 -->
      <!-- 如果不需要用index下标，则index可以不写，写成    v-for="item in list" -->
      <li v-for="(item, index) in list" :key="item.id">
        <input type="checkbox" />
        {{ index }}--{{ item.id }}--{{ item.name }}--{{ item.nickname }}
        <button @click="aa(item.id)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { id: 2, name: "宋江", nickname: "及时雨" },
        { id: 3, name: "吴用", nickname: "智多星" },
        { id: 5, name: "林冲", nickname: "豹子头" },
        { id: 7, name: "花荣", nickname: "小李广" },
      ],
    };
  },
  methods: {
    aa(id) {
      this.list = this.list.filter((item) => {
        return item.id !== id;
      });
    },
  },
};
</script>

<style>
</style>
